import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CategoriesVO, CategoriesForm, CategoriesQuery } from '@/api/content/categories/types';

/**
 * 查询分类管理列表
 * @param query
 * @returns {*}
 */

export const listCategories = (query?: CategoriesQuery): AxiosPromise<CategoriesVO[]> => {
  return request({
    url: '/content/categories/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分类管理详细
 * @param categoryId
 */
export const getCategories = (categoryId: string | number): AxiosPromise<CategoriesVO> => {
  return request({
    url: '/content/categories/' + categoryId,
    method: 'get'
  });
};

/**
 * 新增分类管理
 * @param data
 */
export const addCategories = (data: CategoriesForm) => {
  return request({
    url: '/content/categories',
    method: 'post',
    data: data
  });
};

/**
 * 修改分类管理
 * @param data
 */
export const updateCategories = (data: CategoriesForm) => {
  return request({
    url: '/content/categories',
    method: 'put',
    data: data
  });
};

/**
 * 删除分类管理
 * @param categoryId
 */
export const delCategories = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/content/categories/' + categoryId,
    method: 'delete'
  });
};
